<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Modify extends CI_Controller {

    public function index()
    {

        $this->load->view('login/modify.html');
    }
    public function home(){

             $data=$this->input->post();
             $data['password']=md5($data['password']);
             $date=$this->db->where('phone',$data['phone'])->get('user')->row_array();//调用model里的方法完成验证
            if($data['password']==$date['password']){
                echo "<script type='text/javascript'> alert('新密码与就密码相同');location.href = '/index.php/modify/index';</script>";
                return;
            }
                  $update=array(
                      'password'=> $data['password'],
                      'update_time'=>time()
                  );
                 $this->db->update('user',$update,array('id'=>$date['id']));
                 echo "<script type='text/javascript'> alert('修改密码成功'); location.href = '/index.php/login/index';</script>";
                 return;
             }
//             var_dump($date);
//             die();




}